package com.itheima.advantagesup.vo;

import com.itheima.advantagesup.dto.UserAddDTO;
import com.itheima.advantagesup.entity.SysMenu;
import com.itheima.advantagesup.entity.SysRole;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;
import java.util.StringJoiner;

/**
 * 用户信息签证官
 *
 * @author liudo
 * @date 2023/07/26
 */
@Data
public class UserInfoVO {
    private String id;
    private String login_name;
    private String password;
    private String name;
    private String email;
    private String phone;
    private String login_ip;
    private LocalDateTime login_date;
    private LocalDateTime create_date;
    private LocalDateTime update_date;
    private String del_flag;
    private List<String> role_id;
    private Integer status;
    private List<String> rolename;
    private List<SysMenu> authList;

    public UserAddDTO getUserAddDTO() {
        UserAddDTO userAddDTO = new UserAddDTO();
        userAddDTO.setId(id);
        userAddDTO.setLogin_name(login_name);
        userAddDTO.setPassword(password);
        userAddDTO.setName(name);
        userAddDTO.setEmail(email);
        userAddDTO.setPhone(phone);
        userAddDTO.setLogin_ip(login_ip);
        userAddDTO.setLogin_date(login_date);
        userAddDTO.setCreate_date(create_date);
        userAddDTO.setUpdate_date(update_date);
        userAddDTO.setDel_flag(del_flag);
        if (role_id != null){
            StringJoiner rolenames = new StringJoiner(",", "[\"", "\"]");
            for (String s : role_id) {
                rolenames.add(s);
            }
            userAddDTO.setRole_id(rolenames.toString());
        }
        userAddDTO.setStatus(status);
        return userAddDTO;
    }
}
